home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / boot / netBoot / h / dir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-13  |  2.2 KB  |  71 lines

  1. /*    @(#)dir.h 1.1 86/09/27 SMI; from UCB 4.5 82/11/13    */
  2.  
  3.  
  4. /*
  5.  * A directory consists of some number of blocks each of which is
  6.  * less than or equal to the filesystem block size number of
  7.  * bytes.
  8.  *
  9.  * Each block contains some number of directory entry structures,
  10.  * which are of variable length.  Each directory entry has
  11.  * a struct direct at the front of it, containing its file number,
  12.  * the length of the entry, and the length of the name contained in
  13.  * the entry.  These are followed by the name padded to a 4 byte boundary
  14.  * with null bytes.  All names are guaranteed null terminated.
  15.  * The maximum length of a name in a directory is MAXNAMLEN, plus
  16.  * a null byte.
  17.  *
  18.  * The macro DIRSIZ(dp) gives the amount of space required to represent
  19.  * a directory entry.  Free space in a directory is represented by
  20.  * entries which have dp->d_reclen > DIRSIZ(dp).
  21.  *
  22.  * All the bytes in a directory block are claimed by the directory entries.
  23.  * This usually results in the last entry in a directory having a large
  24.  * dp->d_reclen.  Free entries have their dp->d_fileno set to 0.
  25.  */
  26. #define    MAXNAMLEN    255
  27.  
  28. struct    direct {
  29.     u_long    d_fileno;        /* file number of entry */
  30.     u_short    d_reclen;        /* length of this record */
  31.     u_short    d_namlen;        /* length of string in d_name */
  32.     char    d_name[MAXNAMLEN + 1];    /* name (up to MAXNAMLEN + 1) */
  33. };
  34.  
  35. #ifndef KERNEL
  36. #define d_ino    d_fileno        /* compatablity */
  37.  
  38. /*
  39.  * The DIRSIZ macro gives the minimum record length which will hold
  40.  * the directory entry.  This requires the amount of space in struct direct
  41.  * without the d_name field, plus enough space for the name with a terminating
  42.  * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
  43.  */
  44. #undef DIRSIZ
  45. #define DIRSIZ(dp) \
  46.     ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
  47.  
  48. /*
  49.  * Definitions for library routines operating on directories.
  50.  */
  51. typedef struct _dirdesc {
  52.     int    dd_fd;
  53.     long    dd_loc;
  54.     long    dd_size;
  55.     long    dd_bbase;
  56.     long    dd_entno;
  57.     long    dd_bsize;
  58.     char    *dd_buf;
  59. } DIR;
  60.  
  61. #ifndef NULL
  62. #define NULL 0
  63. #endif
  64. extern    DIR *opendir();
  65. extern    struct direct *readdir();
  66. extern    long telldir();
  67. extern    void seekdir();
  68. #define rewinddir(dirp)    seekdir((dirp), (long)0)
  69. extern    void closedir();
  70. #endif
  71.